package com.javabasic.test;

import java.util.Scanner;
import java.util.TreeSet;

/**
 * @Author xiongmin
 * @ClassName 有序链表合并
 * @Description TODO
 * @Date 2019/8/20 15:30
 * @Version 1.0
 **/
public class 有序链表合并 {

    static Scanner cin = new Scanner(System.in);
    public static void main(String[] args) {
        String str = cin.nextLine();
//        System.out.println(str);
        String[] lists = str.split("\\|");
//        System.out.println(lists[0] + "- -" + lists[1]);
        String[] list1 = null, list2 = null;
        if (lists[0] != "" && lists[0].isEmpty() == false) {
            list1 = lists[0].split(",");
        }
        if (lists[1] != "" && lists[1].isEmpty() == false) {
            list2 = lists[1].split(",");
        }


//        int len1 = list1.length, len2 = list2.length; // 1,2,8|2,4,6,7
//
//        int listVal1[] = new int[len1];
//        int listVal2[] = new int[len2];
//        for (int i = 0; i < len1; i++) {
//            listVal1[i] = Integer.parseInt(list1[i]);
//        }
//        for (int i = 0; i < len2; i++) {
//            listVal2[i] = Integer.parseInt(list2[i]);
//        }
        TreeSet<String> result = new TreeSet<>();
        if (list1 != null && list1.length > 0) {
            for (String s :
                    list1) {
                if (s != null && s != "") {
                    result.add(s);
                }

            }
        }
        if (list2 != null &&list2.length > 0) {
            for (String s :
                    list2) {
                if (s != null && s != "") {
                    result.add(s);
                }
            }
        }


        System.out.print("[");
        boolean flag = false;
        for (String s :
                result) {
            if (flag) {
                System.out.print(",");
            }
            flag = true;
            System.out.print(s);
        }
        System.out.println("]");

    }
}

class Node{

    int val;
    Node next;

    public int getVal() {
        return val;
    }

    public void setVal(int val) {
        this.val = val;
    }

    public Node getNext() {
        return next;
    }

    public void setNext(Node next) {
        this.next = next;
    }
}

